package com.xgure.result;

/**
 * 统一返回结果
 *
 */
public class Result<T> {

    private Integer code;
    private String message;
    private T data;

    // 请求成功
    public static <T> Result<T> success() {
        Result<T> result = new Result<T>();
        result.code = 0;
        return result;
    }

    // 请求成功并返回数据
    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<T>();
        result.code = 0;
        result.data = data;
        return result;
    }

    public static <T> Result<T> error(String message) {
        Result<T> result = new Result<T>();
        result.code = 1;
        result.message = message;
        return result;
    }

}
